/*
包含n个用于间接更新状态的方法的对象模块
 */
import { TOGGLE_COLLAPSE, GET_ROLES, GET_CATEGORY } from './mutation-types'
import axios from 'axios'

export default {
  toggleCollapse ({ commit }) {
    commit(TOGGLE_COLLAPSE)
  },
  async getRoles ({ commit }) {
    const { data: res } = await axios.get('/roles/all')
    if (res.status === 200) {
      commit(GET_ROLES, res.data)
    }
  },
  async getCategorys ({ commit }) {
    const { data: res } = await axios.get('/category/all')
    if (res.status === 200) {
      commit(GET_CATEGORY, res.data)
    }
  }
}
